package main

import (
	"example_1/composite"
	"fmt"
)

func main() {
	saleDepartment := composite.NewDepartment("市场销售部")
	saleLeader := composite.NewEmployee("张哥", 600000)
	saleEmployee1 := composite.NewEmployee("小弟1", 100000)
	saleEmployee2 := composite.NewEmployee("小弟2", 100000)
	saleDepartment.AddSubNode(saleLeader)
	saleDepartment.AddSubNode(saleEmployee1)
	saleDepartment.AddSubNode(saleEmployee2)

	marketDepartment := composite.NewDepartment("市场营销部")
	marketLeader := composite.NewEmployee("李哥", 600000)
	marketEmployee1 := composite.NewEmployee("小弟3", 100000)
	marketEmployee2 := composite.NewEmployee("小弟4", 100000)
	marketDepartment.AddSubNode(marketLeader)
	marketDepartment.AddSubNode(marketEmployee1)
	marketDepartment.AddSubNode(marketEmployee2)

	department := composite.NewDepartment("市场部")
	leader := composite.NewEmployee("王老板", 1000000)
	department.AddSubNode(leader)
	department.AddSubNode(saleDepartment)
	department.AddSubNode(marketDepartment)

	fmt.Println("employee num: ", department.GetEmployeeNum())
	fmt.Println("salary: ", department.CalculateSalary())

	bro3 := department.Search("小弟3")
	if bro3 != nil {
		fmt.Printf("get bro: %s, salary: %d\n", bro3.GetID(), bro3.CalculateSalary())
	}
}
